package com.irishud.hudnavi;

import android.content.Context;
import android.util.Log;

import com.amap.api.maps.model.LatLng;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.AMapNaviListener;
import com.amap.api.navi.enums.AimLessMode;
import com.amap.api.navi.enums.NaviType;
import com.amap.api.navi.enums.PathPlanningStrategy;
import com.amap.api.navi.model.AMapLaneInfo;
import com.amap.api.navi.model.AMapNaviCross;
import com.amap.api.navi.model.AMapNaviInfo;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.AMapNaviPath;
import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo;
import com.amap.api.navi.model.AimLessModeCongestionInfo;
import com.amap.api.navi.model.AimLessModeStat;
import com.amap.api.navi.model.NaviInfo;
import com.amap.api.navi.model.NaviLatLng;
import com.autonavi.tbt.NaviStaticInfo;
import com.autonavi.tbt.TrafficFacilityInfo;
import com.google.gson.Gson;
import com.hud.base.protocol.ProtoMsgEncoder;
import com.irishud.hudnavi.ar_navi.ARHudComm;
import com.irishud.hudnavi.ar_navi.AR_Navi;
import com.irishud.protocol.NaviParams;
import com.irishud.protocol.NaviUpdateInfo;
import com.irishud.protocol.ProtoMsg;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;

public class NaviAdapter implements AMapNaviListener{
	// 电子狗监听回调
	public interface  AimlessStateListener
	{
		void onSpecialRoadAndCameraDetected(String content);
	}
	List<AimlessStateListener> aimlessListener = new ArrayList<AimlessStateListener>();

	private void notifyAimlessStateDetected(String detail)
	{
		synchronized (aimlessListener)
		{
			for(AimlessStateListener o : aimlessListener)
			{
				o.onSpecialRoadAndCameraDetected(detail);
			}
		}
	}

	public  void addAimlessStateListener(AimlessStateListener o)
	{
		synchronized (aimlessListener)
		{
			aimlessListener.add(o);
		}
	}

	public  void removeAimlessStateListener(AimlessStateListener o)
	{
		synchronized (aimlessListener)
		{
			aimlessListener.remove(o);
		}
	}

    public void startAimlessMode()
    {
        if(aMapNavi !=null)
        {
            aMapNavi.startAimlessMode(AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED);
            naviLog("startAimlessMode() 打开电子狗功能");
        }
    }

    public void stopAimlessMode()
    {
        if(aMapNavi !=null)
        {
            aMapNavi.stopAimlessMode();
            naviLog("stopAimlessMode() 关闭电子狗功能");
        }
    }

	// TAG
	private static final String TAG = "NAV" + NaviAdapter.class.getSimpleName();
	// 单例
	private AMapNavi aMapNavi = null;
	private Context context = null;
	private static NaviAdapter naviAdapter = null;
	private volatile boolean isOffTrackHappened = false; // 是否发生偏航
    EventBus eventBus = EventBus.getDefault();

	List<NaviLatLng> mStartPointList = new ArrayList<>();
	List<NaviLatLng> destNavi = new ArrayList<>();
	Set<NaviLatLng> waypoints = new HashSet<>();
	int routeIdForStartNavi = 0;

	public void setRouteSelectedIndex(int index){
		routeIdForStartNavi = index;
	}

	public int getRouteIdForStartNavi(){
		return routeIdForStartNavi;
	}

	public final static  int RequestCode_AddWaypoint = 0x123f;

	private NaviAdapter(Context ctx){
		context = ctx.getApplicationContext();
        aMapNavi = AMapNavi.getInstance(context);
	}

	// 构造函数
	public static NaviAdapter InitInstance() {
		if (naviAdapter == null) {
            synchronized (NaviAdapter.class)
            {
				if (naviAdapter == null) {
					naviAdapter = new NaviAdapter(NaviApp.getInstance());
				}
            }
		}
		return naviAdapter;
	}

	public void setDestNavi(NaviLatLng dest){
		destNavi.add(dest);
	}

	public void addWaypoint(NaviLatLng wp){
		waypoints.add(wp);
	}

    public NaviLatLng getDestNavi(){
        return destNavi.size() > 0 ? destNavi.get(destNavi.size() - 1) : null;
    }

    public Set<NaviLatLng> getWaypointList(){
        return waypoints;
    }

    public void clearNaviParam(){
        destNavi.clear();
        waypoints.clear();
    }

	public  void setaMapNavi(AMapNavi navi){
		aMapNavi = navi;
	}

	public AMapNavi getAmapNavi() {
//		if(aMapNavi==null)
//			aMapNavi = AMapNavi.getInstance(NaviApp.getInstance());
		return aMapNavi;
	}
	
	// 记录导航过程日志
	void naviLog(String logmsg)
	{
		Log.d(TAG,logmsg);
	}
	
	// 析构函数
	public static void FreeInstance() {
		try {
			if (naviAdapter != null) {
				naviAdapter.Close();
				naviAdapter.CloseAMapNaviForPatch();
				naviAdapter = null;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 模块标记
	public volatile boolean isOpen = false;

	public boolean isOpen() {
		return isOpen;
	}

	// 导航标记
	public volatile boolean isNavigating = false;
	// 播报标记
	public volatile boolean isSpeakingNow = false;

	// 规划模式
	public volatile int currentPathPlanningStategy = PathPlanningStrategy.DRIVING_DEFAULT;
	// 导航模式 (0--实际导航,1--模拟导航)
	public volatile int currentNaviMode = 0;
	// 导航播报开关
	public volatile boolean isTTSReady = true;

	// 目的地坐标
	public volatile NaviLatLng currentNaviDestinationLatLng = null;
	// 导航过程中回调数据
	public volatile NaviInfo currentNaviInfo = null;// TODO eventbus

	// 导航UI
	public Sysconfig myconfig;


	public Sysconfig getConfig() {
		if (null == myconfig) {
			myconfig = new Sysconfig(context);
		}
		return myconfig;
	}

	private boolean isNaviPaused = false; // 导航是否被暂停

	// 简单模式与复杂模式切换
	public void switchMode() {
		naviLog("切换导航模式");
		getConfig().setSimpleNaviMode(!getConfig().isSimpleNaviMode());
		if (null != aMapNavi) {
			if (this.isNavigating) {
				naviLog("[switchMode]pause navi");// 切换导航模式:导航可见立即生效；不可见则显示时生效
				aMapNavi.pauseNavi();
				isNaviPaused = true;
				Open(false);
			} else {
				naviLog("[switchMode]wait for next navi");// 切换导航模式:下次导航生效
			}
		}

	}

	public boolean resumeNavi() {
		if (null != aMapNavi) {
			if (this.isNaviPaused) {
				aMapNavi.resumeNavi();
				this.isNaviPaused = false;
				return true;
			}
		}
		return false;
	}

	public void startNavActivity(Runnable callback) {
		naviLog("startNavActivity() :mode=" + getConfig().isSimpleNaviMode());
		// 删除老页面
        eventBus.post(new NaviEvent(NaviEvent.CloseNavi));
		// 打开新页面，由hud 通过Intent调用
		Boolean isSimple = getConfig().isSimpleNaviMode();
	}

	// 打开导航模块
	public void Open(boolean bRouteMode) {
		OpenAMapNaviForPatch();
		// 判断导航状态
		if (isOpen && isNavigating) {
			startNavActivity(null);
		} else {
			isOpen = true;
		}
	}

	@SuppressWarnings("deprecation")
	// 打开导航，会影响到快速导航
	public void OpenAMapNaviForPatch() {
//		try {
//			if (aMapNavi == null) {
//				aMapNavi = AMapNavi.getInstance(NaviApp.getInstance());
//				aMapNavi.addAMapNaviListener(naviAdapter);
//				TtsManager.getInstance(context);
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}
    // 关闭导航
	public void CloseAMapNaviForPatch() {
		naviLog(" CloseAMapNaviForPatch() called");
//		try {
//			if (aMapNavi != null) {
//				aMapNavi.removeAMapNaviListener(naviAdapter);
//				aMapNavi.destroy();
//				aMapNavi = null;
//				isNaviPaused = false;
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}

	public void closePreviousNaviTasks(){
		clearNaviParam();
		if(isNavigating){
			isNavigating = false;
			if(aMapNavi!=null)aMapNavi.stopNavi();
			eventBus.post(new NaviEvent(NaviEvent.CloseNavi));
		}
	}

	// 关闭导航模块吧
	public void Close() {
		naviLog("Close() called : isOpen=" + isOpen);
		try {
			// 关闭导航
			StopNavi();
			isOpen = false;
		} catch (Exception e) {
            e.printStackTrace();
        }
        clearNaviParam();
		isOpen = false;
        multiRouteCalcMode = false;
        eventBus.post(new NaviEvent(NaviEvent.CloseNavi));
	}

	boolean multiRouteCalcMode = false;
    // 多路径规划
	public void multiRoutePlan(NaviLatLng dest,List<NaviLatLng> waypointList)
	{
        // speak("开始多路径规划");
        LocationAdapter locationAdapter = LocationAdapter.InitInstance(NaviApp.getInstance());
        ArrayList<NaviLatLng> startLatlng =new ArrayList<>();
        ArrayList<NaviLatLng> endLatlng =new ArrayList<>();
        ArrayList<NaviLatLng> waypoint =new ArrayList<>();
        if(waypointList!=null && waypointList.size() > 0){
            waypoint.addAll(waypointList);
        }
        if (locationAdapter.locationHasUpdated) { // 当前定位点
            NaviLatLng currentLocation = new NaviLatLng(locationAdapter.lat, locationAdapter.lng);
            startLatlng.add(currentLocation);
        }
//      startLatlng.add(new NaviLatLng(Constants.ShenzhenDaxue.latitude,Constants.ShenzhenDaxue.longitude));
        endLatlng.add(dest);
        if(aMapNavi!=null)
            aMapNavi.calculateDriveRoute(startLatlng, endLatlng, waypoint, PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES);
		multiRouteCalcMode = true;
	}

	public void multiRoutePlanEmulation(NaviLatLng dest,List<NaviLatLng> waypointList)
	{
		// speak("开始多路径规划");
		LocationAdapter locationAdapter = LocationAdapter.InitInstance(NaviApp.getInstance());
		ArrayList<NaviLatLng> startLatlng =new ArrayList<>();
		ArrayList<NaviLatLng> endLatlng =new ArrayList<>();
		ArrayList<NaviLatLng> waypoint =new ArrayList<>();
		if(waypointList!=null && waypointList.size() > 0){
			waypoint.addAll(waypointList);
		}
		if (locationAdapter.locationHasUpdated) { // 当前定位点
			NaviLatLng currentLocation = new NaviLatLng(locationAdapter.lat, locationAdapter.lng);
			startLatlng.add(currentLocation);
		}
//      startLatlng.add(new NaviLatLng(Constants.ShenzhenDaxue.latitude,Constants.ShenzhenDaxue.longitude));
		endLatlng.add(dest);
		currentNaviMode = NaviUseEmulation;
		if(aMapNavi!=null)
			aMapNavi.calculateDriveRoute(startLatlng, endLatlng, waypoint, PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES);
		multiRouteCalcMode = true;
	}

	// 多路径规划,服务器端
	public void multiRoutePlan(NaviLatLng start,NaviLatLng dest, List<NaviLatLng> waypointList,int pathPlanStrategy)
	{
		// speak("开始多路径规划");
		ArrayList<NaviLatLng> startLatlng =new ArrayList<>();
		ArrayList<NaviLatLng> endLatlng =new ArrayList<>();
		ArrayList<NaviLatLng> waypoint =new ArrayList<>();
		if(waypointList!=null && waypointList.size() > 0){
			waypoint.addAll(waypointList);
		}
		startLatlng.add(start);
		endLatlng.add(dest);
		if(aMapNavi!=null){
            // TODO 偏航使能
            aMapNavi.setReCalculateRouteForYaw(true);
            aMapNavi.setReCalculateRouteForTrafficJam(true);
            aMapNavi.calculateDriveRoute(startLatlng, endLatlng, waypoint, pathPlanStrategy);
        }
		multiRouteCalcMode = true;
	}

	// 规划路径
	public void calculateRoute(NaviLatLng naviDestLatLng, int naviMode) {
		// myconfig = new Sysconfig(context);
		OpenAMapNaviForPatch();
		currentNaviMode = naviMode;
		currentNaviDestinationLatLng = naviDestLatLng;
		// 判断定位点
		LocationAdapter locationAdapter = LocationAdapter.InitInstance(NaviApp.getInstance());
		if (locationAdapter.locationHasUpdated) {
			NaviLatLng mNaviStart = new NaviLatLng(locationAdapter.lat, locationAdapter.lng);
			calculateRoute(mNaviStart, naviDestLatLng, naviMode);
		} else {
			ArrayList<NaviLatLng> mEndPoints = new ArrayList<NaviLatLng>();
			mEndPoints.add(naviDestLatLng);
            // 播报提示
            speakAndWait("开始路径计算");
            aMapNavi.calculateDriveRoute(mEndPoints, null, currentPathPlanningStategy);
		}
	}
	
	private boolean getIsTts(){
		return true;
	}

	private void calculateRoute(NaviLatLng mNaviStart, NaviLatLng mNaviEnd,
								int nMode) {
		// myconfig = new Sysconfig(context);
		currentNaviMode = nMode;
		OpenAMapNaviForPatch();
		currentNaviDestinationLatLng = mNaviEnd;
		// 规划路径
		ArrayList<NaviLatLng> mStartPoints = new ArrayList<NaviLatLng>();
		ArrayList<NaviLatLng> mEndPoints = new ArrayList<NaviLatLng>();
		mStartPoints.add(mNaviStart);
		mEndPoints.add(mNaviEnd);
		aMapNavi.calculateDriveRoute(mStartPoints, mEndPoints, null, currentPathPlanningStategy);
		// 播报提示
		speakAndWait("开始路径规划");
	}

	// 启动导航
	public void startNavi() {
		StopNavi();
		if (!isNavigating) {
			if (currentNaviMode == 0) {
				aMapNavi.startNavi(NaviType.GPS);
			} else {


				aMapNavi.setEmulatorNaviSpeed(emulatedSpeed);
				aMapNavi.startNavi(NaviType.EMULATOR);
			}
			isNavigating = true;
		}
	}

	// 停止导航
	private void StopNavi() {
		naviLog("StopNavi() called :isNavigating=" + isNavigating);
		if (isNavigating) {
			aMapNavi.stopNavi();
			isNavigating = false;
		}
		isNaviPaused = false;
	}

	public AMapNaviPath getNaviPath() {
		if (null != aMapNavi)
			return aMapNavi.getNaviPath();

		return null;
	}

	/***************************
	 * com.amap.api.navi.AMapNaviListener的相关回调开始
	 */
	@Override
	public void OnUpdateTrafficFacility(TrafficFacilityInfo arg0) {
		Log.i(TAG, "OnUpdateTrafficFacility");
		int nDist = ((AMapNaviTrafficFacilityInfo) arg0).getDistance();
		int nSpeed = ((AMapNaviTrafficFacilityInfo) arg0).getLimitSpeed();
		String warningWords = "前方" + nDist + "米有摄像头 限速" + nSpeed;
		speak(warningWords);
		naviLog(warningWords);
	}

	@Override
	public void hideCross() {
        eventBus.post(new NaviEvent(NaviEvent.HideCrossRoadInfo));// EventBus post
		Log.i(TAG, "hideCrossView");
	}

	@Override
	public void hideLaneInfo() {
		Log.i(TAG, "hideLaneInfo");
	}
	// 结束导航
	void finishNavi()
	{
        clearNaviParam();
        String wordsToSay = "返回导航主页";
		if(BuildConfig.EN_OfflineTTS){
		}else{
		}
		naviLog("finishNavi() 导航结束");
	}

	@Override
	public void onArriveDestination() {
		naviLog("onArriveDestination() 导航结束");
		finishNavi();
	}

	@Override
	public void onArriveDestination(NaviStaticInfo naviStaticInfo) {

	}

	@Override
	public void onArrivedWayPoint(int arg0) {
		Log.i(TAG, "onArrivedWayPoint");
	}

	@Override
	public void onCalculateRouteFailure(int arg0) {
		speakAndWait("路径计算失败，请检查网络或输入参数");
		naviLog("onCalculateRouteFailure() 路径计算失败，请检查网络或输入参数");
	}

	@Override
	public void onCalculateRouteSuccess() {
        if(recalculateForYaw){//偏航之后计算成功路径
            recalculateForYaw = false;
            final AMapNaviPath naviPath = aMapNavi.getNaviPath();
            if(naviPath!=null){
                Log.i(TAG,"------------------>偏航之后计算成功路径 --------> 发送到AR");
                ARHudComm.getInstance().sendToAR(AR_Navi.sendRefPoint(mStartPointList.get(0).getLatitude(),
                        mStartPointList.get(0).getLongitude()));

				ProtoMsgEncoder notify = new ProtoMsgEncoder(ProtoMsgEncoder.Notify,
						"on_board_navi_route",
						AR_Navi.sendRouteInfoToAR(mStartPointList.get(0),aMapNavi).array());

				NaviFloatWindowService.getInstance().phoneNaviDataSender.send(notify.toBytes());

				notifyPhoneOnBoardNaviRouteUpdate(aMapNavi);
            }
        }
	}

	private void notifyPhoneOnBoardNaviRouteUpdate(AMapNavi aMapNavi)
	{
		final Gson gson = new Gson();
		NaviRouteData naviRouteData = new NaviRouteData();
		naviRouteData.startPoint = aMapNavi.getNaviPath().getStartPoint();
		naviRouteData.endPoint = aMapNavi.getNaviPath().getEndPoint();
		naviRouteData.routePoints = aMapNavi.getNaviPath().getCoordList();
		ProtoMsgEncoder notify = new ProtoMsgEncoder(ProtoMsgEncoder.Notify,
				"onboardnavi.update_route",
				gson.toJson(naviRouteData).getBytes());
		NaviFloatWindowService.getInstance().phoneNaviDataSender.send(notify.toBytes());
	}

	private void notifyPhoneOnBoardNaviLocationUpdate(AMapNaviLocation location){
		final Gson gson = new Gson();
		NaviLocationData locationData = new NaviLocationData();
		locationData.gpsPosition = new LatLng(location.getCoord().getLatitude(),
				                              location.getCoord().getLongitude());
		ProtoMsgEncoder notify = new ProtoMsgEncoder(ProtoMsgEncoder.Notify,
				"onboardnavi.update_location",
				gson.toJson(locationData).getBytes());
		NaviFloatWindowService.getInstance().phoneNaviDataSender.send(notify.toBytes());
	}

	@Override
	public void onEndEmulatorNavi() {
		finishNavi();
		naviLog("onEndEmulatorNavi() 导航结束");
	}

	private void doAsEnd() {
        aMapNavi.startAimlessMode(AimLessMode.CAMERA_AND_SPECIALROAD_DETECTED);// 设置播报电子眼和特殊路段
		// 结束导航
		eventBus.post(new NaviEvent(NaviEvent.CloseNavi));
	}

	@Override
	public void onGetNavigationText(int arg0, String words) {
		if(isNavigating)
		{
			speakAndWait(words);
			naviLog("onGetNavigationText() 高德导航播报:"+words);
			if (words.equals("您已超速")) {
                eventBus.post(new NaviEvent(NaviEvent.WarningOverSpeedLimit));
			}
		}
		else //非导航模式下的电子狗播报
		{
			notifyAimlessStateDetected(words);
			naviLog("##############====> 非导航模式下电子狗播报 :"+words);
		}
	}

	@Override
	public void onGpsOpenStatus(boolean arg0) {
		naviLog("onGpsOpenStatus() ");
	}

	@Override
	public void onInitNaviFailure() {
		Log.i(TAG, "onInitNaviFailure");
		naviLog("导航初始化失败");
	}

	@Override
	public void onInitNaviSuccess() {
		Log.i(TAG, "onInitNaviSuccess");
	}

	@Override
	public void onLocationChange(AMapNaviLocation location) {
        Log.i(TAG, "onNaviLocationChange"); // 当GPS位置有更新时的回调函数。
		eventBus.post(new NaviEvent(NaviEvent.UpdateNaviLocationInfo,location));
		notifyPhoneOnBoardNaviLocationUpdate(location);
	}

	Gson gson = new Gson();
	@Override
	public void onNaviInfoUpdate(NaviInfo naviInfo) {
		currentNaviInfo = naviInfo;
        eventBus.post(new NaviEvent(NaviEvent.UpdateNaviInfo,naviInfo));
		naviLog(" onNaviInfoUpdate() ");
        // TODO  send to AR apk
        Log.i(TAG,"-------------->(OnBardNavi Mode) Navi Updata Info ---> AR");

		ProtoMsgEncoder notify = new ProtoMsgEncoder(ProtoMsgEncoder.Notify,
				"on_board_navi_route",
				AR_Navi.sendNaviInfoToAR(mStartPointList.get(0),naviInfo).array());

		NaviFloatWindowService.getInstance().phoneNaviDataSender.send(notify.toBytes());
		// 串口发送导航数据到非AR小屏幕
		NaviUpdateInfo naviUpdateInfo = new NaviUpdateInfo();
		naviUpdateInfo.nextTurnIcon = naviInfo.getIconType();
		naviUpdateInfo.nextRoadDistance = naviInfo.getCurStepRetainDistance();
		//得到下个路口道路名
		naviUpdateInfo.nextRoadName = naviInfo.getNextRoadName();
		ProtoMsg naviData = new ProtoMsg("updateNaviInfo",gson.toJson(naviUpdateInfo));
		NaviFloatWindowService.getInstance().serialPortSendThread.send(naviData.toBytes());
		NaviFloatWindowService.getInstance().phoneNaviDataSender.send(naviData.toBytes());
	}

	@Override
	public void onReCalculateRouteForTrafficJam() {
		speakAndWait("前方路线拥堵，路线重新规划");
		naviLog("onReCalculateRouteForTrafficJam() 前方路线拥堵，路线重新规划");
	}

    boolean recalculateForYaw = false;
	@Override
	public void onReCalculateRouteForYaw() {
		naviLog("您已偏航 onReCalculateRouteForYaw() called");
        recalculateForYaw = true;
        aMapNavi.reCalculateRoute(currentPathPlanningStategy);
	}

	@Override
	public void onStartNavi(int arg0) {
		naviLog("onStartNavi() called");
        aMapNavi.stopAimlessMode();
	}

	@Override
	public void onTrafficStatusUpdate() {
		Log.i(TAG, "onTrafficStatusUpdate");
	}

	@Override
	public void showCross(AMapNaviCross arg0) {
        eventBus.post(new NaviEvent(NaviEvent.ShowCrossRoadInfo,arg0));
		naviLog("showCrossView() called");
	}

	@Override
	public void showLaneInfo(AMapLaneInfo[] arg0, byte[] arg1, byte[] arg2) {
		naviLog("showLaneInfo() called");
	}

	@Override
	public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo arg0) {

	}

	@Override
	public void notifyParallelRoad(int arg0) {

	}

	@Override
	public void onCalculateMultipleRoutesSuccess(int[] routeIds) {
		eventBus.post(new NaviEvent(NaviEvent.MultiRoutePlanOk,routeIds));
        Log.e(TAG,"--------> (OnBoardNavi Mode) onCalculateMultipleRoutesSuccess() -----send route info to AR");
		aMapNavi.selectRouteId(routeIds[routeIdForStartNavi]);

		notifyPhoneOnBoardNaviRouteUpdate(aMapNavi);//send route to phone map

		ProtoMsgEncoder notify = new ProtoMsgEncoder(ProtoMsgEncoder.Notify,
				"on_board_navi_route",
				AR_Navi.sendRouteInfoToAR(mStartPointList.get(0),aMapNavi).array());
		NaviFloatWindowService.getInstance().phoneNaviDataSender.send(notify.toBytes());

        startNavi();
    }

	@SuppressWarnings("deprecation")
	@Override
	public void onNaviInfoUpdated(AMapNaviInfo arg0) {

	}

	@Override
	public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] arg0) {

	}

	@Override
	public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo info) {
	}

	@Override
	public void updateAimlessModeStatistics(AimLessModeStat stat) {
	}

	// 开启语音播报
	private void speak(String strData) {
		if(BuildConfig.PRODUCT.equals("ds3"))
			return;
	}

	private void speakAndWait(String strData) {
		if(BuildConfig.PRODUCT.equals("ds3"))
			return;
	}


	public  final static int NaviUseGps = 0;
	public  final static int NaviUseEmulation = 1;
	int emulatedSpeed = 36;
	@Subscribe
	public void startNaviFrom(NaviParams naviParams){
		clearNaviParam();
		closePreviousNaviTasks();
		aMapNavi.addAMapNaviListener(naviAdapter);
		mStartPointList.add(naviParams.start);
		destNavi.add(naviParams.end);
		routeIdForStartNavi = naviParams.naviPathSeletedIndex;// 默认选择的第几个线路


		currentNaviMode = naviParams.useGps ? NaviUseGps:NaviUseEmulation;
		currentPathPlanningStategy = naviParams.currentStragtegyForNavi;
		emulatedSpeed = naviParams.emulatedSpeed;
		Log.i("FFFF", "startNaviFrom emulatedSpeed:" + emulatedSpeed);
		multiRoutePlan(naviParams.start ,
				       naviParams.end ,
				       naviParams.waypoints,currentPathPlanningStategy);
		Log.e(TAG,"-------------> NaviAdapter 开始导航");
	}
}
